<?php
/**
 * File:          KValidator_Parameter_Text_Int
 * Description:   -
 * Author:        Kovac "Kovacou'" Alexandre (www.kovacou.fr)
 * Last Update:   21/04/2011
 */

   class KValidator_Parameter_Text_Int implements KValidatorParameter {
      public  $min,
              $max;
      
      public function valid ($value, $config) {
         $options = array ();
         
         if (isset($this->min)) $options['options']['min_range'] = $this->min;
         if (isset($this->max)) $options['options']['max_range'] = $this->max;
         
         if (false === (bool) filter_var ($value, FILTER_VALIDATE_INT, $options))
            if (isset ($this->min, $this->max))
               return sprintf("Doit être compris entre %s et %s", $this->min, $this->max);
            elseif (isset ($this->max))
               return sprintf("Doit avoir un maximum de %s", $this->max);
            else
               return sprintf("Doit avoir un minimum de %s", $this->min);
      }
   }
 
/**
 * End
 * Of
 * File
 */
?>